@extends('master')

@section('content')

      <div class="row-fluid">
          <div class="span3">
            <div class="title">
                  <div class="row-fluid legend">
                      <h3><i class="fa fa-retweet"></i> 物品入库流程
                      </h3>
                  </div>
              </div><!-- End .title -->
              <div class="content">
                  <ul class="nav nav-tabs nav-stacked">
                    @foreach($nodes as $node)
                    <li><a href="javascript:void(0);">{{ $node->step }} {{ $node->des }}</a></li>
                    @endforeach


                  </ul>
              </div> <!-- End .content -->
          </div><!-- End .span3 -->

        <div class="span9">
          <div class="row-fluid legend profile">
            <div class="row-fluid ">
              <div class="span6">
                <h3><i class="fa fa-paper-plane-o"></i> 操作区</h3>

              </div>
              <div class="span6">
                <div class=" pull-right">
                    <a class="btn" href="javascript:history.go(-1)" >
                    <i class="fa fa-hand-o-left"></i> 返回
                    </a>
                  </div>
             </div>
            </div>
          </div> <!-- End .legend -->

              <div class="content spacer-big">
                <h3><span>① 发起【{{ $template->name }}】</span> <small>填写</small></h3>
                {!! Form::open(['url' => route('flows.store'), 'class' => 'form-horizontal', 'id' => '', 'role' => 'form']) !!}
                <span class="form-horizontal row-fluid"  id="my">
                <input type="hidden" name="list_count" id="count" value="1">
                <input type="hidden" name="template_id" value="{{ $template->id }}">
                  <div class="form-row control-group row-fluid">
                <input class="com-id" type="hidden" id="commodity_1" name="commodity_id[]" value="">
                    <div class="controls span4">
                      <div class="input-prepend row-fluid">
                        <span class="add-on prepend "><i class="fa fa-tag"></i></span>
                        <input class="row-fluid com-name" id="input_1" name="name[]" required  size="50" type="text" placeholder="输入关键词，如RO,选择提示的物品名">
                      </div>
                    </div>
                    <div class="controls span2">
                      <div class="input-prepend row-fluid">
                        <span class="add-on prepend "><i class="fa fa-cubes"></i></span>
                        <input class="row-fluid" id="price1" name="count[]" required  size="6" type="text"   placeholder="数量">
                      </div>
                    </div>


                    @if($template->unit_type == 0)
                    <div class="controls span4">
                      <div class="input-prepend row-fluid">
                        <span class="add-on prepend "><i class="fa fa-truck"></i></span>
                        <input class="row-fluid" id="price1" name="gongying[]" required  size="50" type="text"  placeholder="供应商名称尽量标准化">
                      </div>
                    </div>
                    @elseif($template->unit_type == 1 || $template->action_type == -1 )
                    <div class="controls span4">
                      <div class="input-prepend row-fluid">
                        <span class="add-on prepend "><i class="fa fa-cny"></i></span>
                        <input class="row-fluid" id="price1" required  size="50" type="text" name="price[]"  placeholder="物品单价">
                      </div>
                    </div>
                    @endif

                    <div class="controls span2 add">
                      <a href="#" class="btn btn-primary " rel="tooltip" data-placement="left" data-original-title="新增一条"><i class="fa  fa-plus"></i></a>
                    </div>
                  </div>
                  </span>
                <hr class="border_das">

                <!-- 说明开始 -->
                  <div class="form-row control-group row-fluid">
                    <div class="controls span6">
                      <textarea rows="3" name="remark" class="row-fluid autogrow" id="elastic-textarea" placeholder="请备注相关入库情况.."></textarea>
                    </div>


                    @if($template->action_type == -1 && $template->unit_type == 1)
                    <div class="controls span4">
                      <select data-placeholder="选择用途/分销商..." class="chzn-select">
                        <option value=""></option>
                        <option value="United States">自营</option>
                        <option value="United Kingdom">客情费用</option>
                        <option value="Afghanistan">推广资产</option>
                        <option value="Albania">九堡分销商</option>
                        <option value="Algeria">滨江分销商</option>
                        <option value="United States">某某分销商</option>
                      </select>
                    </div>
                    @elseif($template->unit_type == 1)
                    <div class="controls span4">
                      <select data-placeholder="选择收货运营商/城市运营商..." class="chzn-select" name="unit_id">
                        <option value=""></option>
                        @foreach($units as $unit)>
                        <option value="{{ $unit->id }}">{{ $unit->name }}</option>
                        @endforeach

                      </select>
                    </div>
                    @endif
                  </div>
                <!-- 说明结束 -->
                  <div class="form-actions row-fluid">
                    <div class="text-center">
                      <button type="submit" class="btn btn-primary"><i class="fa fa-paper-plane"></i> 提交</button>
                    </div>
                  </div>

            {!! Form::close() !!}
              </div> <!-- End .content -->
          </div><!-- End .span9 -->
      </div><!-- End .row-fluid -->









@stop

@section('script')

<script type='text/javascript'>





    $(window).load(function() {
     $('#loading').fadeOut();
    });
      $(document).ready(function() {
      $('body').css('display', 'none');
      $('body').fadeIn(500);


      $("#logo a, #sidebar_menu a:not(.accordion-toggle), a.ajx").click(function() {
      event.preventDefault();
      newLocation = this.href;
      $('body').fadeOut(500, newpage);
      });
      function newpage() {
      window.location = newLocation;
      };


        // Chosen select plugin
        $(".chzn-select").chosen({
          disable_search_threshold: 10
        });
      $(".add").click(function(){
          // 复制一行
          var count = $('#count').val();
          var new_count = Number(count)+1;
          $('#count').val(new_count);
          var content = "<div class='controls span2 del'><a class='btn btn-inverse del' ><i class='fa  fa-trash'></i></a></div>" ;
          $(this).parent().clone(true).appendTo("#my");
          // 去掉这项
          $("#my .control-group:last-child .add").remove();
          $("#my .control-group:last-child").append(content);
          $("#my .control-group:last-child .com-name").attr("id","input_"+new_count);
          $("#my .control-group:last-child .com-id").attr("id","commodity__"+new_count);
          $("#my .control-group:last-child").find("input").val("");
      });
      $(".del").live('click',function(){
          $(this).closest(".control-group").remove();
      });





    });
    </script>
@stop